home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / vgamaze4.zip / SPIKE.CPP < prev    next >
Text File  |  1994-03-02  |  3KB  |  97 lines

  1. //      This program plots
  2. // z=2.0*cos(7.0*sqrt(x*x+y*y))*cos(7.0*sqrt(x*x+y*y))/(1.0+30.0*(x*x+y*y))
  3. // in three dimensions on a VGA display.
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <math.h>
  8. #include <stdlib.h>
  9. #include <conio.h>
  10. #include <iostream.h>
  11. #include "titillat.h"
  12. #include "plot3d.h"
  13. #include "vga3d.h"
  14.  
  15. #ifndef TRUE
  16. #define TRUE -1
  17. #endif
  18. #ifndef FALSE
  19. #define FALSE 0
  20. #endif
  21.  
  22. static int    external_to_plot(double,double);
  23. static double f(double,double);
  24.        int    main(void);
  25. static int    red(double,double);
  26.  
  27. extern unsigned _stklen=0x8000;
  28.  
  29. int main()
  30.     {
  31.       static   int    fatal_error;
  32.       static   double light_x;
  33.       static   double light_y;
  34.       static   double light_z;
  35.       static   int    response;
  36.       static   double rotation;
  37.       static   double tilt;
  38.       static   vga3d  *vga3d_ptr;
  39.  
  40.       fatal_error=FALSE;
  41.       vga3d_ptr=new vga3d();
  42.       rotation=(double) 0.0;
  43.       tilt=(double) 30.0;
  44.       light_x=(double) 1.0;
  45.       light_y=(double) -1.0;
  46.       light_z=(double) 1.0;
  47.       if (vga3d_ptr->prepare_plot(f, // function f(x,y) to be plotted
  48.        -1.0,                         // minimum x
  49.        1.0,                          // maximum x
  50.        -1.0,                         // minimum y
  51.        1.0,                          // maximum y
  52.        external_to_plot,             // don't plot -- always FALSE
  53.        red,                          // highlight -- always FALSE
  54.        120,                          // number of x divisions
  55.        120,                          // number of y divisions
  56.        rotation,                     // rotation in degrees
  57.        tilt,                         // tilt in degrees
  58.        light_x,light_y,light_z))     // vector to light source
  59.         {
  60.           if (vga3d_ptr->plot("",     // output file name
  61.                               FALSE,  // highlight flagged areas
  62.                               FALSE,  // amuse user while plotting
  63.                               1.0))   // contrast adjustment
  64.             {
  65.               fflush(stdin);
  66.               response=getch();
  67.               fflush(stdin);
  68.             }
  69.         }
  70.       delete vga3d_ptr;
  71.       return(fatal_error);
  72.     }
  73.  
  74. static int external_to_plot(
  75.   double x,
  76.   double y)
  77.     {
  78.        return FALSE;
  79.     }
  80.  
  81. static int red(
  82.   double x,
  83.   double y)
  84.     {
  85.        return FALSE;
  86.     }
  87.  
  88. static double f(
  89.   double x,
  90.   double y)
  91.     {
  92.        double t1=x*x+y*y;
  93.        double t2=cos(7.0*sqrt(t1));
  94.        return 2.0*t2*t2/(1.0+30.0*t1);
  95.     }
  96. 
  97.